<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
    <meta name="author" content="">
    <title></title>  <link rel="icon" href="/template/pc1/images/wmh_favicon.ico" type="image/x-icon" />
    <% include("../inc/list_css.html"){}%>
</head>
<body>
<div class="ibox ">
    <div class="ibox-title">
        <div class="pull-left mbx navbar_title">
            <span>订单管理 </span>
            <span class="line">/</span>
            订单审核
        </div>
    </div>

    <div class="ibox-content">
        <div class="wrapper wrapper-content">
            <div class="row">
                <div class="col-sm-12" >
                    <div class="alert alert-warning alert-dismissable">
                        <button aria-hidden="true" data-dismiss="alert" class="close" type="button">×</button>
                        可以对订单进行搜索和处理，方便的对已有订单进行处理.
                    </div>
                    <div class="tabs-container margin-vertical-20_10" >
                        <ul class="nav nav-tabs">
                            <li class="active"><a data-toggle="tab" href="#tab-1" aria-expanded="false">已付款</a>
                            </li>
                            <li class=""><a data-toggle="tab" href="#tab-2" aria-expanded="false">待付款</a>
                            </li>
                            <li class=""><a data-toggle="tab" href="#tab-3" aria-expanded="false">退款中</a>
                            </li>
                            <li class=""><a data-toggle="tab" href="#tab-4" aria-expanded="false">已退款</a>
                            </li>
                        </ul>
                        <div class="tab-content">
                            <div id="tab-1" class="tab-pane active">
                                <div class="panel-body">
                                    <div class="btn-group margin-vertical-4_0" style="margin-top: 13px">
                                        <button class="hive-btn-md-large hive-btn-primary" id="batchcheck">
                                            &nbsp;一键审核
                                        </button>
                                    </div>
                                    <table id="yfkTableEvents" data-toggle="table" data-mobile-responsive="true">
                                        <thead>
                                        <tr>
                                            <th data-field="a" data-checkbox="true"></th>
                                            <th data-field="orderSn">订单编号</th>
                                            <th data-field="trade_no">第三方流水号</th>
                                            <th data-field="code">会员编号</th>
                                            <th data-field="username">昵称</th>
                                            <th data-field="shipName">收件人</th>
                                            <th data-field="" data-formatter="addressFormatter">收件人地址</th>
                                            <th data-field="productTotalQuantity">订单数量</th>
                                            <th data-field="orderDetail" >商品</th>
                                            <th data-field="totalAmount">订单总额</th>
                                            <th data-field="paymentStatus" data-formatter="paymentStatusF">付款状态</th>
                                            <!--<th data-field="shippingStatus" data-formatter="shippingStatusF">配送状态</th>-->
                                            <th data-field="paymentConfigName">支付方式</th>
                                            <!--<th data-field="deliveryTypeName">配送方式</th>-->
                                            <th data-field="createDate">下单时间</th>
                                            <th data-field="head" data-formatter="yfkheadFormatter">操作</th>
                                        </tr>
                                        </thead>
                                    </table>
                                </div>
                            </div>
                            <div id="tab-2" class="tab-pane">
                                <div class="panel-body">
                                    <table id="dfkTableEvents" data-toggle="table" data-mobile-responsive="true">
                                        <thead>
                                        <tr>
                                            <th data-field="a" data-checkbox="true"></th>
                                            <th data-field="orderSn">订单编号</th>
                                            <th data-field="trade_no">第三方流水号</th>
                                            <th data-field="code">会员编号</th>
                                            <th data-field="username">昵称</th>
                                            <th data-field="shipName">收件人</th>
                                            <th data-field="" data-formatter="addressFormatter">收件人地址</th>
                                            <th data-field="productTotalQuantity">订单数量</th>
                                            <th data-field="orderDetail" >商品</th>
                                            <th data-field="totalAmount">订单总额</th>
                                            <th data-field="paymentStatus" data-formatter="paymentStatusF">付款状态</th>
                                            <!--<th data-field="shippingStatus" data-formatter="shippingStatusF">配送状态</th>-->
                                            <th data-field="paymentConfigName">支付方式</th>
                                            <!--<th data-field="deliveryTypeName">配送方式</th>-->
                                            <th data-field="createDate">下单时间</th>
                                            <th data-field="head" data-formatter="dfkheadFormatter">操作</th>
                                        </tr>
                                        </thead>
                                    </table>
                                </div>
                            </div>
                            <div id="tab-3" class="tab-pane">
                                <div class="panel-body">
                                    <table id="tkzTableEvents" data-toggle="table" data-mobile-responsive="true">
                                        <thead>
                                        <tr>
                                            <th data-field="a" data-checkbox="true"></th>
                                            <th data-field="orderSn">订单编号</th>
                                            <th data-field="trade_no">第三方流水号</th>
                                            <th data-field="code">会员编号</th>
                                            <th data-field="username">昵称</th>
                                            <th data-field="shipName">收件人</th>
                                            <th data-field="" data-formatter="addressFormatter">收件人地址</th>
                                            <th data-field="productTotalQuantity">订单数量</th>
                                            <th data-field="orderDetail" >商品</th>
                                            <th data-field="totalAmount">订单总额</th>
                                            <th data-field="paymentStatus" data-formatter="paymentStatusF">付款状态</th>
                                            <!--<th data-field="shippingStatus" data-formatter="shippingStatusF">配送状态</th>-->
                                            <th data-field="paymentConfigName">支付方式</th>
                                            <!--<th data-field="deliveryTypeName">配送方式</th>-->
                                            <th data-field="createDate">下单时间</th>
                                            <th data-field="head" data-formatter="tkzheadFormatter">操作</th>
                                        </tr>
                                        </thead>
                                    </table>
                                </div>
                            </div>
                            <div id="tab-4" class="tab-pane">
                                <div class="panel-body">
                                    <table id="ytkTableEvents" data-toggle="table" data-mobile-responsive="true">
                                        <thead>
                                        <tr>
                                            <th data-field="a" data-checkbox="true"></th>
                                            <th data-field="orderSn">订单编号</th>
                                            <th data-field="trade_no">第三方流水号</th>
                                            <th data-field="code">会员编号</th>
                                            <th data-field="username">昵称</th>
                                            <th data-field="shipName">收件人</th>
                                            <th data-field="" data-formatter="addressFormatter">收件人地址</th>
                                            <th data-field="productTotalQuantity">订单数量</th>
                                            <th data-field="orderDetail" >商品</th>
                                            <th data-field="totalAmount">订单总额</th>
                                            <th data-field="paymentStatus" data-formatter="paymentStatusF">付款状态</th>
                                            <!--<th data-field="shippingStatus" data-formatter="shippingStatusF">配送状态</th>-->
                                            <th data-field="paymentConfigName">支付方式</th>
                                            <!--<th data-field="deliveryTypeName">配送方式</th>-->
                                            <th data-field="createDate">下单时间</th>
                                            <th data-field="head" data-formatter="ytkheadFormatter">操作</th>
                                        </tr>
                                        </thead>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


<% include("../inc/list_js.html"){}%>
<script>
    //收件人地址转换
    function addressFormatter(value, row, index) {
        return row.shipArea+'&nbsp;&nbsp;'+row.shipAddress;
    }

    //var start={elem:"#start",format:"YYYY/MM/DD hh:mm:ss",min:laydate.now(),max:"2099-06-16 23:59:59",istime:true,istoday:false,choose:function(datas){end.min=datas;end.start=datas}};var end={elem:"#end",format:"YYYY/MM/DD hh:mm:ss",min:laydate.now(),max:"2099-06-16 23:59:59",istime:true,istoday:false,choose:function(datas){start.max=datas}};laydate(start);laydate(end);
    //支付状态:0-未支付,1-部分支付,2-已支付,3-部分退款,4-全额退款
    function paymentStatusF(v) {
        if(v == 0){
            return "未支付";
        }else if(v == 1){
            return "部分支付";
        }else if(v == 2){
            return "已支付";
        }else if(v == 3){
            return "部分退款";
        }else if(v == 4){
            return "全额退款";
        }else if(v == 5){
            return "退款申请中";
        }
    }
    //物流状态:0-未发货,1-部分发货,2-已发货,3-部分退货,4-已退货
    function shippingStatusF(v) {
        if(v == 0){
            return "未发货";
        }else if(v == 1){
            return "部分发货";
        }else if(v == 2){
            return "已发货";
        }else if(v == 3){
            return "部分退货";
        }else if(v == 4){
            return "已退货";
        }
    }


    function yfkheadFormatter(value, row, index){
        var html = '<a class="am-text-secondary" href="view?orders.id='+row.id+'" title="查看">[查 看]</a>';
        if(row.checks == 0){
            html += '<a class="am-text-secondary" href="###" onclick="check(\''+row.id+'\')" title="审核">[审核]</a>';
        }else{
            html += '[审核通过]';
        }
        return html;
    }

    function dfkheadFormatter(value, row, index){
        var html = '<a class="am-text-secondary" href="view?orders.id='+row.id+'" title="查看">[查 看]</a>';
            html += '<a class="am-text-secondary" href="process?orders.id='+row.id+'&type=cw" title="处理">[处 理]</a>';

        return html;
    }

    function tkzheadFormatter(value, row, index){
        var html = '<a class="am-text-secondary" href="view?orders.id='+row.id+'" title="查看">[查 看]</a>';
        html += '<a class="am-text-secondary" href="process?orders.id='+row.id+'&type=wl" title="处理">[处 理]</a>';
            /*html += '<a href="javascript:void(0)" class="am-text-secondary" onclick="agreeRefund(\''+row.id+'\');" data-toggle="tooltip" data-placement="top" title="[同意退款]">[同意退款]</a>';*/
        return html;
    }
    function ytkheadFormatter(value, row, index){//
        var html = '<a class="am-text-secondary" href="view?orders.id='+row.id+'" title="查看">[查 看]</a>';

        return html;
    }


    function queryParams() {
        var params = {};
        $('#toolbar').find('input[name]').each(function () {
            params[$(this).attr('name')] = $(this).val();
        });
        $('#toolbar').find('select').each(function () {
            params[$(this).attr('name')] = $(this).val();
        });
        return params;
    }

    var $dfktable = $('#dfkTableEvents');
    var $yfktable = $('#yfkTableEvents');
    var $tkztable = $('#tkzTableEvents');
    var $ytktable =$("#ytkTableEvents")
    $ok = $('#ok');


    function check(id) {
        parent.layer.confirm('您确定审核通过吗?操作后状态不可更改,请谨慎操作!', {
            shade: [0.3,'#fff'],//0.1透明度的白色背景
            btn: ['是','否'] //按钮
        }, function(){
            $.post('check',{"id":id},function (e) {
                if(e){
                    parent.layer.closeAll();
                    layer.msg('审核成功');
                    $dfktable.bootstrapTable('refresh');
                    $yfktable.bootstrapTable('refresh');
                    $tkztable.bootstrapTable('refresh');
                    $ytktable.bootstrapTable('refresh');
                }
            });
        });
    }


    function agreeRefund(orderId) {
        parent.layer.confirm('您确定要退款吗?', {
            shade: [0.3,'#fff'],//0.1透明度的白色背景
            btn: ['是','否'] //按钮e.state == "fail"
        }, function(){
            $.post('refund',{"orderId":orderId},function (e) {
                if(e.state == "fail"){
                    parent.layer.msg(e.info);
                }else{
                    parent.layer.msg("操作成功!");
                    $dfktable.bootstrapTable('refresh');
                    $yfktable.bootstrapTable('refresh');
                    $tkztable.bootstrapTable('refresh');
                    $ytktable.bootstrapTable('refresh');
                }
            })
        });


    }

    $(function () {
        $ok.click(function () {
            $dfktable.bootstrapTable('refresh');
            $yfktable.bootstrapTable('refresh');
        });
    });


    (function() {
        var dfktable = $('#dfkTableEvents').bootstrapTable({
            url: "ajaxlist?status=dfk",
            dataType: 'json',
            contentType: 'application/json',
            search: true,
            searchAlign: 'right',
            pagination: true,
            showRefresh: true,
            pageSize: 20,
            showToggle: false,//是否显示card/table切换按钮
            showColumns: true,//是否显示内容列下拉框
            pageList: [20, 50, 100],
            iconSize: 'outline',
            toolbar: '#eventsToolbar',
            paginationHAlign: 'right', //right, left
            paginationVAlign: 'bottom',
            icons: {
                refresh: 'icon-refresh',
                toggle: 'glyphicon-list-alt',
                columns: 'icon-select',
                export: 'icon-export'
            },
            responseHandler: function (res) {
                $("#dsh").html(res.length);
                return res;
            },
            formatNoMatches: function () { //判断有无数据
                var imghtml = '<div class="flexed_column content_center content_alignCenter padding-20"><img src="https://static.9hive.cn/global/img/nodata.png" class="no_data"/><span class="font-size-16">暂无数据</span></div>';
                return imghtml;
            },
            formatLoadingMessage: function () {  //数据加载中样式
                return ' <div id="loading"><div id="loading-center">' +
                    '<div id="loading-center-absolute"><div class="object" id="object_one">' +
                    '</div><div class="object" id="object_two"></div><div class="object" id="object_three">' +
                    '</div><div class="object" id="object_four"></div></div></div>努力加载中...</div>'
            },
        });
        var yfktable = $('#yfkTableEvents').bootstrapTable({
            url: "ajaxlist?status=yfk",
            dataType: 'json',
            contentType: 'application/json',
            search: true,
            searchAlign: 'right',
            pagination: true,
            showRefresh: true,
            pageSize: 20,
            showToggle: false,//是否显示card/table切换按钮
            showColumns: true,//是否显示内容列下拉框
            pageList: [20, 50, 100],
            iconSize: 'outline',
            toolbar: '#eventsToolbar',
            paginationHAlign: 'right', //right, left
            paginationVAlign: 'bottom',
            icons: {
                refresh: 'icon-refresh',
                toggle: 'glyphicon-list-alt',
                columns: 'icon-select',
                export: 'icon-export'
            },
            responseHandler: function (res) {
                $("#dsh").html(res.length);
                return res;
            },
            formatNoMatches: function () { //判断有无数据
                var imghtml = '<div class="flexed_column content_center content_alignCenter padding-20"><img src="https://static.9hive.cn/global/img/nodata.png" class="no_data"/><span class="font-size-16">暂无数据</span></div>';
                return imghtml;
            },
            formatLoadingMessage: function () {  //数据加载中样式
                return ' <div id="loading"><div id="loading-center">' +
                    '<div id="loading-center-absolute"><div class="object" id="object_one">' +
                    '</div><div class="object" id="object_two"></div><div class="object" id="object_three">' +
                    '</div><div class="object" id="object_four"></div></div></div>努力加载中...</div>'
            },
        });

        var tkztable = $('#tkzTableEvents').bootstrapTable({
            url: "ajaxlist?status=tkz",
            dataType: 'json',
            contentType: 'application/json',
            search: true,
            searchAlign: 'right',
            pagination: true,
            showRefresh: true,
            pageSize: 20,
            showToggle: false,//是否显示card/table切换按钮
            showColumns: true,//是否显示内容列下拉框
            pageList: [20, 50, 100],
            iconSize: 'outline',
            toolbar: '#eventsToolbar',
            paginationHAlign: 'right', //right, left
            paginationVAlign: 'bottom',
            icons: {
                refresh: 'icon-refresh',
                toggle: 'glyphicon-list-alt',
                columns: 'icon-select',
                export: 'icon-export'
            },
            responseHandler: function (res) {
                $("#dsh").html(res.length);
                return res;
            },
            formatNoMatches: function () { //判断有无数据
                var imghtml = '<div class="flexed_column content_center content_alignCenter padding-20"><img src="https://static.9hive.cn/global/img/nodata.png" class="no_data"/><span class="font-size-16">暂无数据</span></div>';
                return imghtml;
            },
            formatLoadingMessage: function () {  //数据加载中样式
                return ' <div id="loading"><div id="loading-center">' +
                        '<div id="loading-center-absolute"><div class="object" id="object_one">' +
                        '</div><div class="object" id="object_two"></div><div class="object" id="object_three">' +
                        '</div><div class="object" id="object_four"></div></div></div>努力加载中...</div>'
            },
        });

        var ytktable = $('#ytkTableEvents').bootstrapTable({
            url: "ajaxlist?status=ytk",
            dataType: 'json',
            contentType: 'application/json',
            search: true,
            searchAlign: 'right',
            pagination: true,
            showRefresh: true,
            pageSize: 20,
            showToggle: false,//是否显示card/table切换按钮
            showColumns: true,//是否显示内容列下拉框
            pageList: [20, 50, 100],
            iconSize: 'outline',
            toolbar: '#eventsToolbar',
            paginationHAlign: 'right', //right, left
            paginationVAlign: 'bottom',
            icons: {
                refresh: 'icon-refresh',
                toggle: 'glyphicon-list-alt',
                columns: 'icon-select',
                export: 'icon-export'
            },
            responseHandler: function (res) {
                $("#dsh").html(res.length);
                return res;
            },
            formatNoMatches: function () { //判断有无数据
                var imghtml = '<div class="flexed_column content_center content_alignCenter padding-20"><img src="https://static.9hive.cn/global/img/nodata.png" class="no_data"/><span class="font-size-16">暂无数据</span></div>';
                return imghtml;
            },
            formatLoadingMessage: function () {  //数据加载中样式
                return ' <div id="loading"><div id="loading-center">' +
                    '<div id="loading-center-absolute"><div class="object" id="object_one">' +
                    '</div><div class="object" id="object_two"></div><div class="object" id="object_three">' +
                    '</div><div class="object" id="object_four"></div></div></div>努力加载中...</div>'
            },
        });

        $("#batchcheck").click(function () {
            var ids = $.map(yfktable.bootstrapTable('getSelections'), function(row) {
                return row.id
            });
//            ids = ["fweqwefw","fqwefqwef"];
            if (ids.length<1) {
                layer.msg("请选择需要审核的订单");
                return;
            }

            parent.layer.confirm('您确定要一键审核吗?操作后状态不可更改,请谨慎操作!', {
                shade: [0.3,'#fff'],//0.1透明度的白色背景
                btn: ['是','否'] //按钮
            }, function(){
                $.post('batchcheck',{"ids":ids},function (e) {
                    if(e){
                        parent.layer.closeAll();
                        layer.msg('审核成功');
                        $dfktable.bootstrapTable('refresh');
                        $yfktable.bootstrapTable('refresh');
                    }
                });
            });

        });
    })();

    function getIdSelections() {
        console.log( $.map($('#yfkTableEvents').bootstrapTable('getSelections'), function(row) {
            return row.id
        }))
    }
</script>
</body>
</html>